//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_DEBUG_RENDER_H
#define _UX_DEBUG_RENDER_H

#include <Includes.h>

namespace Engine
{
namespace CoreSystems
{

	//
	// Debug Render
	//

	class _EXPORT_ CDebugRender : public CEngBaseObject
	{
	public:
		struct TFragOutput
		{
			gl_tex_component::type	eColorType;
			uint					uLocation;
			///
			TFragOutput(): eColorType(gl_tex_component::NONE), uLocation(-1) {}
			TFragOutput(gl_tex_component::type type, uint loc): eColorType(type), uLocation(loc) {}

			bool operator > (const TFragOutput &right) const {
				return uLocation > right.uLocation;
			}

			bool operator == (const TFragOutput &right) const {
				return eColorType == right.eColorType && uLocation == right.uLocation;
			}

			bool operator != (const TFragOutput &right) const {
				return !( *this == right );
			}
		};

		typedef static_array< TFragOutput, UX_GL_MAX_DRAW_BUFFERS >		fragout_array_t;

	private:
		Ptr< GLFrameBuffer >	_pCurrentFB;
		va_info_array_t			_aMeshAttribs,
								_aProgramAttribs;
		fragout_array_t			_aFragOutputs,
								_aFrameBufferInput;
		bool					_bCacheFrameBuffer : 1;

	public:
		CDebugRender();
		~CDebugRender();

		void SetMeshAttribs(const va_info_array_t &aAttribs)			{ _aMeshAttribs = aAttribs; }
		void SetProgramAttribs(const va_info_array_t &aAttribs)			{ _aProgramAttribs = aAttribs; }
		void SetProgramOutput(const fragout_array_t &aOutput)			{ _aFragOutputs = aOutput; }
		void SetFrameBuffer(GLFrameBuffer *pFB)							{ _pCurrentFB = pFB;  _bCacheFrameBuffer = false; }
		bool ChackProgramIO();
	};

//-------------------------------------------------------------------

}	// CoreSystems
}	// Engine

#endif	// _UX_DEBUG_RENDER_H
